package com.rpc.demo.consumer;

import com.rpc.demo.consumer.consumerServer.RpcServiceProxy;
import com.rpc.demo.consumer.consumerServer.ServiceSubscribe;
import com.rpc.demo.common.dto.BookDTO;
import com.rpc.demo.provider.service.BookServiceImpl;
import com.rpc.demo.provider.service.IBookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author: ZhaoJie
 * @Date: 2022/4/7
 * @Description:
 * @Modify: ===================================================
 * Modifier        Modifytime        Description
 * ===================================================
 */

public class User {
    private static Logger logger = LoggerFactory.getLogger(User.class);

    public static void main(String[] args) {
        //在注册中心订阅服务, 获取服务所在的url, 然后通过代理远程调用服务
        ServiceSubscribe serviceSubscribe = new ServiceSubscribe();
        RpcServiceProxy rpcServiceProxy = new RpcServiceProxy(serviceSubscribe);
        //获取RPC代理
        IBookService bookService = (IBookService) rpcServiceProxy.getProxy(IBookService.class);
        BookDTO bookInfo = bookService.getBookInfo(1);
        logger.info(String.valueOf(bookInfo));
    }
}
